package org.example;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Grammar {
    Set<String> terminals = new HashSet<>();
    Set<String> nonTerminals = new HashSet<>();
    String startSymbol;
    List<Production> productions = new ArrayList<>();

    /**
     * 添加终结符
     * @param terminal
     */
    public void addTerminal(String terminal){
        terminals.add(terminal);
    }

    /**
     * 添加非终结符
     * @param nonTerminal
     */
    public void addNonTerminal(String nonTerminal){
        nonTerminals.add(nonTerminal);
    }

    /**
     * 设置开始符号
     * @param startSymbol
     */
    public void setStartSymbol(String startSymbol){
        this.startSymbol = startSymbol;
    }

    /**
     * 添加产生式
     * @param production
     */
    public void addProduction(Production production){
        productions.add(production);
    }

}
